***************************************************************
************************************************
**** LOCALS TO KEEP /"
local main "main.dta"
local main_long "main_long.dta"
local payoffs_long  "payoffs_long.dta"
local employers_long "employers_long.dta"
local predictors "predictors.dta"
local youth_long "youth_long.dta"
local free_response "free_response.dta"

********************************************
*****(V=allmath) Sec 2.8: des stats, t-tests, k-s tests about absolute performance and beliefs  
*****(V=t_selfpro) Sec 3.1: des stats, t-tests, k-s tests of self-evals    

foreach v in allmath t_selfpro { 
clear
clear matrix  
use `main'

keep if `v' ==1 

foreach s in   female male  all  { 
estpost summarize num_correct  belief  belief_gap ///  
	perf_1 perf_2 bucket_1 bucket_2 ///
	apply_1 apply_2 succeed_1 succeed_2 /// 
	if  `s' ==1  , detail
	eststo `s'
}

**Confirm sign diff 
foreach d in num_correct belief belief_gap ///
		perf_1 perf_2 bucket_1 bucket_2 ///
	apply_1 apply_2 succeed_1 succeed_2 {
ttest `d', by(female)
ksmirnov `d', by(female)
}

***** Averages   
esttab  female male  all /// 	
	using `out'des_`v'.tex /// 
 	,  cells("mean(fmt(2))" )   /// 
	title("`v': descriptive statis") /// 
	mtitles("Female"  "Male" "All") ///
	nogaps  compress /// 
	  label   replace
	  
}
*/  
*****************************************************************
*** Figure 1: Distributions of absolute performance and beliefs 

clear
clear matrix  
use `main'	
		
keep if allmath ==1 

***** Figure 1: PANEL A 
local tnum_correct  "Performance"

foreach d in   num_correct     { 

cumul `d'  if female ==1 , gen(`d'F)
cumul `d'  if male ==1 , gen(`d'M)
sort `d'F `d'M

twoway 	line `d'M `d'  if male ==1  /// 
	, fcolor(ltblue ) lcolor(blue )   lwidth(vthick) lpattern(shortdash)  /// 
	legend(label(1 "Male Participants")) /// 
	||  line `d'F `d'  if female ==1  /// 
	, fcolor(none) lcolor(black)   lwidth(vthick) lpattern(solid)  /// 
	legend(label(2 "Female Participants")) /// 
	xtitle("`t`d''  ", size(medium))   /// 
	ytitle("CDF ", size(medium))   /// 
	legend(cols(2)) legend(order( 2 1 ) )  /// 
	graphregion(color(white)) bgcolor(white) ///
	legend(off) /// 
	xsize(4) ysize(4) 
		
 graph export `out'Figure1A.pdf, replace 
 
 }

***** Figure 1: PANELS B and C  
local tbelief  "Absolute Performance Beliefs"
local tbelief_gap  "Absolute Performance Beliefs - Performance "
local beliefL "Figure1B"
local belief_gapL "Figure1C"

foreach d in   belief belief_gap          { 

cumul `d'  if female ==1 , gen(`d'F)
cumul `d'  if male ==1 , gen(`d'M)
sort `d'F `d'M

local xbelief_gap " xlabel(-15(5)15) "
local xlinebelief_gap " xline(0) "

twoway 	line `d'M `d'  if male ==1  /// 
	, fcolor(ltblue ) lcolor(blue )   lwidth(vthick) lpattern(shortdash)  /// 
	legend(label(1 "Male Participants")) /// 
	||  line `d'F `d'  if female ==1  /// 
	, fcolor(none) lcolor(black)   lwidth(vthick) lpattern(solid)  /// 
	legend(label(2 "Female Participants")) /// 
	xtitle("`t`d''  ", size(medium))   /// 
	ytitle("CDF ", size(medium))   /// 
	`x`d''  `xline`d'' /// 
	legend(cols(2)) legend(order( 2 1 ) )  /// 
	legend(off) /// 
	graphregion(color(white)) bgcolor(white) ///
	xsize(4) ysize(4)
	
 graph export `out'``d'L'.pdf, replace 
 
}
	
*/
************************************************************************
************************************************************************
*** Tables 2 and 3 

clear
clear matrix  
use `main_long'

local tperf "Performance" 
local tapply "Willingness-to-Apply" 
local tsucceed "Success" 
local tbucket "Performance-Bucket" 
 
 
***  Table 1: Panels 1-6 and 10-12; Table 2 Panels 1-6 and 10-12 (regressions for versions with informed evals only) 
foreach v in	 t_selfpro t_private t_risky ///
	t_private2 t_norms2  ///
	t_private3   ///
	t_private5  t_verbal5 ///
	allself  { 
	foreach j in  uninform  inform   { 	
foreach d in bucket perf apply succeed     { 

   regress  `d'_   female  /// 
	ncorr*  /// 
	if `j' == 1   & `v' ==1    /// 
 ,  noconstant vce(robust)    
 eststo F`j'`v'`d'
 } 
 
esttab  F`j'`v'perf    ///
	 F`j'`v'bucket  /// 
	 F`j'`v'apply   ////
	  F`j'`v'succeed ///
  	using `out'regMain_`v'_`j'.tex /// 
 	, b(2) se(2)  /// 
	title(" `v' `j' : OLS of Evaluations ") /// 
	mgroups(  "`tperf'"  "`tbucket'"  "`tapply'"  "`tsucceed'"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	mtitles(" FEs"  "FEs" " FEs"  "FEs"    ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', FEs, SEs clustered at subject level")  replace
}	
} 

***  Table 3: Panels 7, 8 , 9 (regressions for versions with informed evals only) 
foreach v in    t_imm3  t_imm4 t_other4   { 
foreach j in   inform  { 	
foreach d in  bucket perf apply succeed     { 
 
 regress  `d'_   female  /// 
	ncorr*  /// 
	if `j' == 1   & `v' ==1    /// 
 ,  noconstant vce(robust)    
 eststo F`j'`v'`d'
 
 } 
 
esttab  F`j'`v'perf    ///
	 F`j'`v'bucket  /// 
	 F`j'`v'apply   ////
	  F`j'`v'succeed ///
  	using `out'regMain_`v'_`j'.tex /// 
 	, b(2) se(2)  /// 
title(" `v' `j' : OLS of Evaluations ") /// 
	mgroups(  "`tperf'"  "`tbucket'"  "`tapply'"  "`tsucceed'"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	mtitles(" FEs"  "FEs" " FEs"  "FEs"    ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', FEs, SEs clustered at subject level")  replace
} 
}

*/

********************************************************
***************************************************************
*** Figure 2 

clear
clear matrix  
use `main'


keep if t_selfpro ==1 

local tperf_1 "Performance Evaluations" 
local tapply_1 "Willingness-to-Apply Evaluations" 
local tsucceed_1 " Success Evaluations" 
local tbucket_1 "Performance-Bucket Evaluations" 
local perf_1L "A" 
local bucket_1L "B"
local apply_1L "C"
local succeed_1L "D"

foreach d in   perf_1 bucket_1 apply_1 succeed_1   { 
	
cumul `d'  if female ==1 , gen(`d'F)
cumul `d'  if male ==1 , gen(`d'M)
sort `d'F `d'M

twoway 	line `d'M `d'  if male ==1  /// 
	, fcolor(ltblue ) lcolor(blue )   lwidth(vthick) lpattern(shortdash)  /// 
	legend(label(1 "Male Participants")) /// 
	||  line `d'F `d'  if female ==1  /// 
	, fcolor(none) lcolor(black)   lwidth(vthick) lpattern(solid)  /// 
	legend(label(2 "Female Participants")) /// 
		legend(off) /// 
	xtitle("`t`d''  ", size(medium))   /// 
	ytitle("CDF ", size(medium))   /// 
	legend(cols(2)) legend(order( 2 1 ) )  /// 
	graphregion(color(white)) bgcolor(white) ///
	xsize(4) ysize(4)  
	
 graph export `out'Figure2``d'L'.pdf, replace 

 }
 
*/ 


************************************************************************
************************************************************************
*** Table 4: Youth Data 

foreach j in inform uninform   { 	
foreach d in  bucket perf apply succeed     { 
clear
clear matrix  
use `youth_long'

keep if `j' ==1 

foreach g in  6 7 8 9 10  11 12 { 
 quietly  regress  `d'_   female   ///
	 ncorr* /// 
	if   grade ==`g' /// 
 ,  noconstant vce(robust)    
 eststo g`g'
} 
 
esttab  g6 g7 g8 g9 g10 g11 g12 ///
  	using `out'regByG_`d'_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("OLS of `j' `d' evaluations, by grade in school ") /// 
	drop(ncorr*) ///
	order(female  ) /// 
	mtitles("6" "7" "8" "9" "10"  "11" "12"   ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("perf FEs, SEs clustered at subject level")  replace
}
} 
*/
 
***********************************************************
***************************************************************
***Appendix Table A.1: Performance and Belief regressions 

foreach v in allmath  { 

clear
clear matrix  
use `main'

keep if `v' ==1  

foreach d in num_correct  belief  belief_gap      { 

 quietly  regress `d'   female     /// 
 , vce(robust)    
 eststo r`d'

 quietly regress `d'   female    ncorr*  /// 
 , noconstant vce(robust)    
 eststo F`d'
 }
 
 esttab    rnum_correct   rbelief  Fbelief    rbelief_gap  /// 
	using `out'regPerfBelief_`v'.tex /// 
 	, b(2) se(2)  /// 
	title("`v' : OLS of Performance and Performance Beliefs ") /// 
	mgroups(  "Perf, No FEs"   "Belief, No FEs"  "Belief, FEs"  "Belief - Perf, No FEs", pattern(1  1  1  1     ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	nomtitles /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', SEs robust")  replace
}
*/

************************************************************************
************************************************************************
*** Appenidx Table A.2: impact of information on performance 

clear
clear matrix  
use `main_long'
 
foreach v in	 t_selfpro allself2  { 
foreach d in bucket perf apply succeed     { 

   regress  `d'_   female inform femaleXinform  /// 
	ncorr*  /// 
	if `v' ==1    /// 
 ,  noconstant vce(cluster subject)    
 eststo F`v'`d'
 } 
 
esttab  F`j'`v'perf    ///
	 F`j'`v'bucket  /// 
	 F`j'`v'apply   ////
	  F`j'`v'succeed ///
  	using `out'regXinform_`v'.tex /// 
 	, b(2) se(2)  /// 
	title(" `v'  : OLS of `j' Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	mtitles(" FEs"  "FEs" " FEs"  "FEs"    ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', FEs, SEs clustered at subject level")  replace	
} 

*/

************************************************************************
************************************************************************
*** Appenidx Table A.3: impact of promotion incentives 

clear
clear matrix  
use `main_long'

keep if t_selfpro==1 | t_private ==1 

foreach j in   inform  uninform { 	
foreach d in bucket perf apply succeed     { 
   regress  `d'_   female t_selfpro femaleXt_selfpro  /// 
	ncorr*  /// 
	if `j' == 1  ///
 ,  noconstant vce(robust)    

 eststo F`d'
 } 
 
esttab  Fperf    ///
	 Fbucket  /// 
	 Fapply   ////
	 Fsucceed ///
  	using `out'regXselfpro_`j'.tex /// 
 	, b(2) se(2)  /// 
	title(" Self-Promotion and Private Versions: OLS of `j'  Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	mtitles(" FEs"  "FEs" " FEs"  "FEs"    ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', FEs, SEs are robust")  replace	
}
*/

***********************************************************
***************************************************************
***Appendix Table A.4: Deservingness Measure 

clear
clear matrix  
use `main'

keep if alleval ==1 

quietly regress deserve   female    ncorr*  /// 
 , noconstant vce(robust)    
 eststo r 
  
  esttab   r	using `out'reg_deserve.tex /// 
 	, b(2) se(2)  /// 
	title("Among Private versions about own math performance: OLS of deservingness measure ") /// 
	nomtitles /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', SEs clustered at subject level")  replace

*/


************************************************************************
************************************************************************
*** Appendix Tables A.5 -A.7 and A.10-A.14

foreach j in  uninform  inform   { 
clear
clear matrix  
use `main_long'

keep if allself ==1 & `j' ==1 

g num_correct_notdemeaned = num_correct


foreach x in  age educ_num feel_repub   num_correct  belief   belief_gap {
summarize `x' , detail
replace `x' = `x' - `r(mean)'
replace `x'Xfemale = `x'*female 
}

 
foreach d in bucket perf apply succeed     { 

*** A.5 -- no FEs
foreach d in bucket perf apply succeed     { 
   regress  `d'_   female  /// 
 ,  constant vce(robust)    
 eststo NFE`d'

** A.6 - demographic controls   
 regress  `d'_   female  /// 
   age educ_num feel_repub     /// 
   ncorr* /// 
 ,  noconstant vce(robust)    
 eststo D`d'
 
** A.7 -Exlude low performers  
  regress  `d'_   female  /// 
   ncorr* /// 
	if num_correct_notdemeaned >=6 /// 
   ,  noconstant vce(robust)    
 eststo L`d'	

** A.10: Interact with performance 
  regress  `d'_      female num_correct   /// 
	num_correctXfemale /// 
	,   vce(robust)    
 eststo P`d'
 

** A.11: Interact with performance when excluding low performers 
  regress  `d'_      female num_correct   /// 
	num_correctXfemale /// 
	if num_correct_notdemeaned >=6 /// 
	,   vce(robust)    
 eststo LP`d' 

 ** A.12 - Interact with demographics   
 regress  `d'_   female  /// 
   age educ_num feel_repub     /// 
   ageXfemale educ_numXfemale feel_repubXfemale     /// 
   ncorr* /// 
 ,  noconstant vce(robust)    
 eststo XD`d'
 
  ** A.13 - Interact with beliefs 
 regress  `d'_   female  /// 
   belief beliefXfemale     /// 
   ncorr* /// 
 ,  noconstant vce(robust)    
 eststo B`d'

   ** A.14 - Interact with belief - performance
 regress  `d'_   female  /// 
   belief_gap       belief_gapXfemale     /// 
   ncorr* /// 
 ,  noconstant vce(robust)    
 eststo BG`d'

 } 
**** Appendix Table A.5: without performance FEs 
 esttab  NFEperf    NFEbucket  NFEapply   NFEsucceed ///
  	using `out'regNFE_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("All self-evaluations about math performance: OLS of `j' Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', no perf FEs, robust SEs")  replace
} 

**** Appendix Table A.6: controlling for other demographics   
esttab  Dperf    Dbucket  Dapply   Dsucceed ///
  	using `out'regDemoControls_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("When controlling for demographics, all self-evaluations about math performance: OLS of Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) drop(ncorr*) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', perf FEs, robust SEs")  replace
	
**** Appendix Table A.7: excluding low performers 
esttab  Lperf      Lbucket    Lapply     Lsucceed ///
  	using `out'regExLowPerf_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("Excluding low performers, all self-evaluations about math performance: OLS of `j' Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) drop(ncorr*) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', perf FEs, robust SEs")  replace

**** Appendix Table A.10: interactions with performance 
esttab  Pperf      Pbucket      Papply       Psucceed ///
  	using `out'regXPerf_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("Interactions with perfromance, all self-evaluations about math performance: OLS of `j' Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', no perf FEs, robust SEs")  replace

**** Appendix Table A.11: interactions with performance when excluding low performers 
esttab  LPperf        LPbucket        LPapply         LPsucceed ///
  	using `out'regExLowPerfXPerf_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("Interactions with perfromance when excluding low performers, all self-evaluations about math performance: OLS of `j' Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', no perf FEs, robust SEs")  replace

**** Appendix Table A.12: interactions with  demographics   
esttab  XDperf    XDbucket  XDapply   XDsucceed ///
  	using `out'regXDemoControls_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("Interactions with demographics, all self-evaluations about math performance: OLS of Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) drop(ncorr*) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', perf FEs, robust SEs")  replace
	

**** Appendix Table A.13: interactions with  beliefs   
esttab  Bperf    Bbucket  Bapply   Bsucceed ///
  	using `out'regXbelief_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("Interactions with absolute performance belief, all self-evaluations about math performance: OLS of Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) drop(ncorr*) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', perf FEs, robust SEs")  replace	

	**** Appendix Table A.14: interactions with  belief - performance   
esttab  BGperf    BGbucket  BGapply   BGsucceed ///
  	using `out'regXbgap_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("Interactions with (absolute performance belief - performance), all self-evaluations about math performance: OLS of Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) drop(ncorr*) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', perf FEs, robust SEs")  replace	
			
} 
*/

*****************************************************************
************************************************************************
*** Appendix Table A.8: Quantile regressions 

foreach j in  uninform  inform   { 
clear
clear matrix  
use `main_long'

keep if allself ==1 & `j' ==1 

foreach q in 25 50 75 { 
foreach d in perf    apply succeed     { 
   bsqreg   `d'_   female   /// 
	ncorr*  /// 
 ,   quantile(`q')  reps(100)
 eststo `d'`q'
}
   esttab perf`q'  apply`q' succeed`q'    ///
  	using `out'regQ`q'_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title(" All self-evaluations about math performance: quantile regression for q = `q'  ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	mtitles("FEs"  "FEs" " FEs"  "FEs" " FEs"  "FEs" " FEs"  "FEs"    ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("FEs ")  replace	

}	
} 

*/


***********************************************************
***************************************************************
*** Appendix Table A.9: Ordered probit 

foreach j in  uninform  inform   { 
clear
clear matrix  
use `main_long'

keep if allself ==1 & `j' ==1 

quietly  oprobit bucket  female /// 
,   vce(robust)    
 eststo  nofe
 
quietly  oprobit bucket  female	ncorr*  /// 
 ,   vce(robust)    
 eststo fe
  
esttab  nofe fe  /// 
		 using `out'regProbit_allself_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("All self-evaluations about math performance:  Oprobit of   `j' performance-bucket evaluations ") /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	mtitles("No FEs"  "FEs"  ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("robust SEs")  replace

}
*/

**************************************************** 
**************************************************** 
*** Appendix Tables A15 (s = t_private5)
*** Appendix Tables A16 (s = t_verbal5)

foreach s in  t_verbal5  t_private5 { 
foreach j in  uninform  inform   { 
clear
clear matrix  
use `main_long'

keep if `s' ==1 & `j' ==1 


*** DEMEANING 
*sindex
foreach x in    general_math general_verbal {
summarize `x' , detail
replace `x' = `x' - `r(mean)'
replace `x'Xfemale = `x'*female 
}

local gt_verbal5 "general_verbal	general_verbalXfemale"
local gt_private5 "general_math general_mathXfemale"

foreach d in  bucket perf apply succeed     { 

quietly  regress  `d'_   female  ///
	`g`s'' /// 
	ncorr*  /// 
	, noconstant  vce(robust)    
 eststo G`d'
  } 
 
 
***OUTPUT WITH FES 

 esttab   Gperf Gbucket Gapply Gsucceed    ///
  	using `out'regXgenbelief_`s'_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("`s' : OLS of `j' Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	drop( ncorr* ) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', FEs, robust SEs")  replace
 
 }
 } 
 
*/


*****************************************************
***************************************************************
***  Panel 1 of A.17 and Panel 1 of A.18  

clear
clear matrix  
use `employers_long'

foreach i in  perf bucket apply succeed  { 
 regress wage   answer  /// 
	if `i'==1 /// 
 , vce(cluster subject)    
 eststo `i'w 
 
  regress hired   answer  /// 
	if `i'==1 /// 
 , vce(cluster subject)    
 eststo `i'h
 }


 ** Panel 2 of A17 
  esttab   perfh bucketh applyh succeedh    ///
	using `out'reg_emp_hired.tex /// 
	, b(2) se(2)  nomtitles /// 
	title("Employer version: ols of hired the worker") /// 
	mgroups( "Performance"  "Performance Bucket"  "Apply" "Succeed", pattern(1 1 1 1 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	nogaps nonumbers compress /// 
	label  /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("SEs clustered at employer level")  replace
	

 ** Panel 2 of A18
  esttab   perfw bucketw applyw succeedw    ///
	using `out'reg_emp_wage.tex /// 
	, b(2) se(2)  nomtitles /// 
	title("Employer version: ols of wage given to worker") /// 
	mgroups( "Performance"  "Performance Bucket"  "Apply" "Succeed", pattern(1 1 1 1 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	nogaps nonumbers compress /// 
	label  /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("SEs clustered at employer level")  replace	

*/

************************************************************
***************************************************************
***  Panel 2 of A.17 and Panel 2 of A.18  	

clear
clear matrix  
use `payoffs_long'


foreach d in  bucket perf apply succeed     { 
 
 quietly  regress  wage_`d'   female  /// 
	ncorr*  /// 
 ,  noconstant vce(cluster subject)    
 eststo `d'w
 
quietly   regress  hired_`d'   female /// 
	ncorr*  /// 
 ,  noconstant vce(cluster subject)    
 eststo `d'h
 } 
 
**** Panel 2 of A.17
 esttab   perfh bucketh applyh succeedh /// 
  	using `out'regEHired.tex /// 
 	, b(2) se(2)  /// 
	title("In Self-Pro versions, OLS of Expected Hiring Probability given evaluation ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("FEs, SEs clustered at worker level")  replace	

	
**** Panel 2 of A.18
 esttab   perfw bucketw applyw succeedw /// 
  	using `out'regEWage.tex /// 
 	, b(2) se(2)  /// 
	title("In Self-Pro versions, OLS of Expected Wage given evaluation ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("FEs,  SEs clustered at worker level")  replace	
*/


**********************************************************************
************************************************************************
***  Appenidx Table A.19: Predictors 
/*
clear
clear matrix  
use `predictors'

foreach d in  perf bucket apply succeed     { 
  quietly  regress  pred_`d'   fpred    ///
	female fpredXfemale	///
	,   vce(cluster subject)    
 eststo `d'
  } 
 
***OUTPUT WITH FES 
 esttab    perf bucket apply succeed  /// 
  	using `out'reg_predictions.tex /// 
 	, b(2) se(2)  /// 
	title("OLS of Predictions about performance of Participants ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("`s', FEs, SEs clustered at subject level")  replace
*/

************************************************************************
************************************************************************
*** Appendix Tables 20-25: Youth Data 

foreach j in inform uninform   { 	
clear
clear matrix  
use `youth_long'

keep if `j' ==1 

foreach x in     num_correct belief      belief_gap ///
	overall_gpa_non   {
summarize `x', detail
replace `x' = `x' - `r(mean)'
replace `x'Xfemale = `x'*female 
}

local ivP "num_correct num_correctXfemale"
local ivB "belief beliefXfemale  "
local ivBgap "belief_gap belief_gapXfemale "
local ivM "minority minorityXfemale "
local ivF "frpl frplXfemale "
local ivG " overall_gpa_non overall_gpa_nonXfemale "

****REGRESS with no FES 
foreach z in P   { 
foreach d in  bucket perf apply succeed     { 
quietly  regress  `d'_   female   /// 
	`iv`z''  ///
	if `j' == 1       /// 
 ,   vce(robust)    
 eststo `d'`z'
 }
 }
 

****REGRESS with performance FES 
foreach z in B Bgap M F G   { 
foreach d in  bucket perf apply succeed     { 
quietly  regress  `d'_   female   /// 
	`iv`z''  ///
	 ncorr*   /// 
	if `j' == 1       /// 
 ,  noconstant vce(robust)    
 eststo `d'`z'
 }
 }
 
*** Appendix Tables A20
 foreach z in P   { 
 esttab   perf`z' bucket`z'  apply`z' succeed`z' /// 
  	using `out'reg`z'_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("OLS of `j' Self-Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("no perf FEs, robust SEs")  replace
 }	
 *** Appendix Tables A21 - A25 
 foreach z in B Bgap M F G   { 
 esttab   perf`z' bucket`z'  apply`z' succeed`z' /// 
  	using `out'reg`z'_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("OLS of `j' Self-Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("perf FEs, robust SEs")  replace
}
} 
 
*/


************************************************************************
************************************************************************
*** Appenidx Table B.1 

foreach j in    uninform   inform { 	
clear
clear matrix  
use `free_response'

keep	if `j' == 1  /// 

foreach d in  cpro  cpredS cpredF cwage          { 
 quietly  regress  `d'   female  /// 
	ncorr*   /// 
 ,  noconstant vce(robust)    
 eststo `d'
 }
  
 esttab cpro  cpredS cpredF cwage     /// 
	using `out'regFree_`j'.tex /// 
 	, b(2) se(2)  /// 
	title("In repsonse to `j' free response, OLS of Free Response OUtcome ") /// 
	mgroups("Self-Pro" "Predicted Score"   "Predicted Female" "Wage"  , pattern(1  1 1   ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	nomtitles /// 
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("Robust SEs")  replace
	
} 

*/
 
************************************************************************
************************************************************************
*** Appenidx Table C.1 

clear
clear matrix  
use `main_long'

keep if allself2 ==1 
	
foreach d in bucket perf apply succeed     { 
*** Panel 1 
   regress  `d'_   female  /// 
	ncorr*  /// 
	if  uninform ==1   ///
 ,  noconstant vce(robust)    
 eststo `d'u 

 *** Panel 2 
   regress  `d'_   female  /// 
	ncorr*  /// 
	if inform ==1   ///
 ,  noconstant vce(robust)    
 eststo `d'i
 

 *** Panel 3 
   regress  `d'_   female  /// 
	ncorr* nbelief*   /// 
	if uninform ==1  ///
	,  noconstant vce(robust)    
 eststo `d'c 
 } 

 ****Appenidx C1: Panel 1 
esttab  perfu bucketu applyu succeedu    ///
  	using `out'regC1.tex /// 
 	, b(2) se(2)  /// 
	title(" All self-evaluations about math performance in versions with uninformed and informed evaluations: OLS of Uninformed Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	mtitles(" FEs"  "FEs" " FEs"  "FEs"    ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("perf FEs, robust SEs")  replace

*Appendix Table C.1 Panel 2
esttab  perfi bucketi applyi succeedi    ///
  	using `out'regC2.tex /// 
 	, b(2) se(2)  /// 
	title(" All self-evaluations about math performance in versions with uninformed and informed evaluations: OLS of Informed Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr* ) /// 
	mtitles(" FEs"  "FEs" " FEs"  "FEs"    ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("perf FEs, robust SEs")  replace

*Appendix Table C.1 Panel 3 
esttab    perfc bucketc applyc succeedc    ///
  	using `out'regC3.tex /// 
 	, b(2) se(2)  /// 
	title(" All self-evaluations about math performance in versions with uninformed and informed evaluations: OLS of Uninformed Evaluations ") /// 
	mgroups(  "Performance"  "Performance-Bucket"  "Willingess-to-Apply" "Success"  , pattern(1  1 1 1    ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  /// 
	order(female  ) /// 
	drop( ncorr*  nbelief*  ) /// 
	mtitles(" FEs"  "FEs" " FEs"  "FEs"    ) ///
	nogaps  compress /// 
	  label   /// 
 	 star(* 0.10 ** 0.05 *** 0.01 )  /// 
	addnote("belief FEs, perf  FEs, robust SEs")  replace
	
	*/
